package com.member.web.controller.shop;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.member.shop.domain.SysBizMessage;
import org.springframework.security.access.prepost.PreAuthorize;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.member.common.annotation.Log;
import com.member.common.core.controller.BaseController;
import com.member.common.core.domain.AjaxResult;
import com.member.common.enums.BusinessType;
import com.member.shop.domain.SysBizMarketPageCategoryData;
import com.member.shop.service.ISysBizMarketPageCategoryDataService;
import com.member.common.utils.poi.ExcelUtil;
import com.member.common.core.page.TableDataInfo;

/**
 * 【营销页面分类关联数据】控制器
 *
 * @author lixinchen
 * @version 1.0
 * @date 2025-01-20
 **/
@RestController
@RequestMapping("/shop/marketPageCategoryData")
public class SysBizMarketPageCategoryDataController extends BaseController {
    @Resource
    private ISysBizMarketPageCategoryDataService sysBizMarketPageCategoryDataService;

    private void setTenantId(SysBizMarketPageCategoryData sysBizMarketPageCategoryData) {
        Long tenantId = getTenantId();
        if (tenantId != null && tenantId > 0) {
            sysBizMarketPageCategoryData.setTenantId(tenantId);
        }
    }
    /**
     * 查询营销页面分类关联数据列表
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBizMarketPageCategoryData sysBizMarketPageCategoryData) {
        startPage();
        setTenantId(sysBizMarketPageCategoryData);
        List<SysBizMarketPageCategoryData> list = sysBizMarketPageCategoryDataService.selectSysBizMarketPageCategoryDataList(sysBizMarketPageCategoryData);
        return getDataTable(list);
    }

    /**
     * 导出营销页面分类关联数据列表
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:export')")
    @Log(title = "营销页面分类关联数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBizMarketPageCategoryData sysBizMarketPageCategoryData) {
        setTenantId(sysBizMarketPageCategoryData);
        List<SysBizMarketPageCategoryData> list = sysBizMarketPageCategoryDataService.selectSysBizMarketPageCategoryDataList(sysBizMarketPageCategoryData);
        ExcelUtil<SysBizMarketPageCategoryData> util = new ExcelUtil<SysBizMarketPageCategoryData>(SysBizMarketPageCategoryData.class);
        util.exportExcel(response, list, "营销页面分类关联数据数据");
    }

    /**
     * 获取营销页面分类关联数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysBizMarketPageCategoryDataService.selectSysBizMarketPageCategoryDataById(id));
    }

    /**
     * 新增营销页面分类关联数据
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:add')")
    @Log(title = "营销页面分类关联数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBizMarketPageCategoryData sysBizMarketPageCategoryData) {
        return toAjax(sysBizMarketPageCategoryDataService.insertSysBizMarketPageCategoryData(sysBizMarketPageCategoryData));
    }

    /**
     * 修改营销页面分类关联数据
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:edit')")
    @Log(title = "营销页面分类关联数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBizMarketPageCategoryData sysBizMarketPageCategoryData) {
        return toAjax(sysBizMarketPageCategoryDataService.updateSysBizMarketPageCategoryData(sysBizMarketPageCategoryData));
    }

    /**
     * 删除营销页面分类关联数据
     */
    @PreAuthorize("@ss.hasPermi('shop:marketPageCategoryData:remove')")
    @Log(title = "营销页面分类关联数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysBizMarketPageCategoryDataService.deleteSysBizMarketPageCategoryDataByIds(ids));
    }
}
